<?php slot('lender','active'); ?>
<div class="row-fluid">	
				<div class="box span12">
					<div class="box-header">
						<h2><i class="icon-user"></i>模块导航</h2>
					</div>
					<div class="box-content">
                                          <ul class="nav tab-menu nav-tabs" id="myTab">
							<li class="active"><a href="#info">功能</a></li>
							<li><a href="#custom">统计信息</a></li>
						</ul>
                                          <div id="myTabContent" class="tab-content">
                                              <div class="tab-pane active" id="info">
<!--						<a class="quick-button-small span1" href="<?php // echo url_for('user/add'); ?>">
							<i class="icon-edit"></i>
							<p>新增用户</p>
							<span class="notification blue">7</span>
						</a>-->
                         <a class="quick-button-small span1" href="<?php echo url_for('lender/add'); ?>">
							<i class="icon-file-alt"></i>
							<p>发布</p>
							<!--<span class="notification blue">7</span>-->
						</a>
                        <a class="quick-button-small span1" id="check_all" href="javascript:;">
							<i class="icon-ok"></i>
							<p>全选</p>
							<!--<span class="notification blue">7</span>-->
						</a>
                                                <a class="quick-button-small span1" id="delete_all" href="javascript:;">
							<i class="icon-share-alt"></i>
							<p>删除</p>
							<!--<span class="notification blue">7</span>-->
						</a>
						<div class="clearfix"></div>
                                                </div>
                                            <div class="tab-pane" id="custom">
                                              <div class="row-fluid">
				
                                                    <div class="span3 smallstat box mobileHalf noMargin" ontablet="span6" ondesktop="span3">
                                                            <i class="icon-user green"></i>
                                                            <span class="title">项目总数</span>
                                                            <span class="value"><?php echo $pager->getNbResults() ?></span>
                                                    </div>
                                            </div>
                                              
                                            </div>
                                          </div>
					</div>	
				</div><!--/span-->
                                
			</div>
<div class="row-fluid">	
      <div class="box span12">
              <div class="box-header">
                      <h2>
                        <i class="icon-align-justify"></i><span class="break"></span>
                        借款列表
                      </h2>
                      <div class="box-icon">
<!--                              <a href="#" class="btn-setting"><i class="icon-wrench"></i></a>
                              <a href="#" class="btn-minimize"><i class="icon-chevron-up"></i></a>
                              <a href="#" class="btn-close"><i class="icon-remove"></i></a>-->
                      </div>
              </div>
              <div class="box-content">
                <?php if($sf_user->hasFlash('error')): ?>
                <div class="alert alert-error">
                        <button type="button" class="close" data-dismiss="alert">×</button>
                        <strong>错误！</strong>  <?php echo $sf_user->getFlash('error'); ?>
                </div>
                <?php endif; ?>
                <?php if($sf_user->hasFlash('success')): ?>
                <div class="alert alert-success">
                        <button type="button" class="close" data-dismiss="alert">×</button>
                        <strong>操作成功！</strong> <?php echo $sf_user->getFlash('success'); ?>
                </div>
                <?php endif; ?>
                <?php if($sf_user->hasFlash('notice')): ?>
                <div class="alert alert-info">
                        <button type="button" class="close" data-dismiss="alert">×</button>
                        <strong><?php echo $sf_user->getFlash('notice'); ?></strong> 
                </div>
                <?php endif; ?>
                <div class="row-fluid">
                  <div class="span6">
                    <div class="dataTables_filter" id="DataTables_Table_0_filter">
                      <form action="<?php echo url_for('user/search'); ?>" method="post">
                      <label>
                        用户名: <input type="text" name="email" />  <button class="btn btn-small btn-primary" style="margin-top:-10px;">搜索</button>
                      </label>
                      </form>
                    </div>
                  </div>
                </div>
                <form id="delete_all_form" action="<?php echo url_for('user/delete_ids'); ?>" method="post" >
                      <table id="data-list" class="table table-bordered table-striped table-condensed">
                                <thead>
                                        <tr>
                                                <th class="center"></th>
                                                <th class="center">用户名</th>
                                                <th class="center">标题</th>
                                                <th class="center">借款用途</th>
                                                <th class="center">列表类型</th>
                                                <th class="center">借款金额</th>
                                                <th class="center">借款状态</th>
                                                <th class="center">发布时间</th>
                                                <th class="center">操作</th>                                      
                                        </tr>
                                </thead>
                                <tbody>
                                  <?php foreach($pager->getResults() as $loan): ?>
                                      <tr>
                                        <td class="center"><input type="checkbox" name="ids[]" value="<?php echo $loan->getId(); ?>" /></td>
                                              <td class="center"><?php echo $loan->getUserName(); ?></td>
                                              <td class="center">
                                                <?php echo $loan->getTitle(); ?>
                                              </td>
                                              <td class="center">
                                                <?php echo $loan->getPurposeToString(); ?>
                                              </td>
                                              <td class="center">
                                                <?php echo $loan->getListTypeToString(); ?>
                                              </td>
                                              <td class="center">
                                                <?php echo number_format($loan->getMoney(),2); ?>
                                              </td>
                                              <td class="center">
                                              <span class="label <?php echo $loan->getStatusToClassName(); ?>"><?php echo Loan::$status[$loan->getStatusAndChange()]; ?></span>
                                              </td>
                                              <td class="center">
                                              <?php echo $loan->getDateTimeObject('created_at')->format('Y-m-d'); ?>
                                              </td>
                                              <td class="center ">
                                                  <a class="btn btn-success" title="查看更多信息" target="_blank" href="<?php echo url_for('lender/show_info?id='.$loan->getId()); ?>">
                                                            <i class="icon-zoom-in "></i>                                            
                                                  </a>
                                                  <a class="btn btn-info" href="<?php echo url_for('lender/edit?id='.$loan->getId()); ?>">
                                                            <i class="icon-edit "></i>                                            
                                                    </a>
                                                  <?php if($loan->getStatusAndChange() == 2 && !$loan->isCheck()): ?>
                                                  <a class="btn btn-warning" title="审核" href="<?php echo url_for('lender/check?id='.$loan->getId()); ?>">
                                                            <i class="icon-check ">审核</i>                                            
                                                    </a>
                                                  <?php endif; ?>
                                                    <a class="btn btn-danger" href="<?php // echo url_for('user/delete?id='.$user->getId()); ?>">
                                                            <i class="icon-trash "></i> 
                                                    </a>
					   </td>
                                      </tr>       
                                      <?php endforeach; ?>
                                </tbody>
                       </table>  
                  </form>
                <?php echo pager_navigation($pager, 'lender/index'); ?>
              </div>
      </div><!--/span-->
</div>
<script type="text/javascript">
 $(document).ready(function(){
//   $( "#dialog" ).dialog();
  
  $("#check_all").toggle(function(){
    $("#data-list > TBODY ").find("input[type=checkbox]").attr('checked','checked').parent('SPAN').addClass('checked');
  },function(){
    $("#data-list > TBODY ").find("input[type=checkbox]").removeAttr('checked').parent('SPAN').removeClass('checked');
  });
  
  $("#delete_all").click(function(){
    var select_num = 0;
    $("#data-list > TBODY ").find("input[type=checkbox]").each(function(){
      if($(this).attr('checked') === 'checked'){
        select_num+=1;
      }
    });
    
    if(select_num == 0){
      alert("请先选择需要删除的数据！");
      return false;
    }
    
    $("#delete_all_form").submit();
    
  });
  
  $("#data-list > TBODY > TR").find("TD:eq(10) > A:eq(0)").click(function(){

     var more_info = eval('('+$(this).attr('more_info')+')');
     
     var score = more_info.score,
         fans_num = more_info.fans,
         idols_num = more_info.idols_num,
         account = more_info.account;  
         
     $("#dialog > SPAN:eq(0)").html(score);
     $("#dialog > SPAN:eq(1)").html(fans_num);
     $("#dialog > SPAN:eq(2)").html(idols_num);
     
     $( "#dialog" ).dialog({
       title: account,
       modal:true
     });
  });

 });
</script>